from django import forms

from registration.forms import RegistrationForm, RegistrationFormUniqueEmail, RegistrationFormTermsOfService
from registration.models import RegistrationProfile

from brispon.models import SiteUser

class SiteUserForm(RegistrationFormUniqueEmail):
    mobile = forms.CharField(max_length=20)
    
    def clean_mobile(self):
        data = self.cleaned_data['mobile']
        
        if len(data) != 10:
            raise forms.ValidationError("Wrong Mobile Number.")
        
        if not data.startswith('0'):
            raise forms.ValidationError("Wrong Mobile Number.")
        
        if not data.isdigit():
            raise forms.ValidationError("Wrong Mobile Number.")
        
        return data
